<template>
    <div>
        <img :src="base64Code" class="qrimage"/>
        <div class="mt12">
            <a type="primary" @click="downloadPDF">下载PDF</a>
            |
            <a type="primary" :href="link" target="_blank">打开视频</a>
        </div>
    </div>
</template>

<script>
    import qrcode from 'yaqrcode'
    import { jsPDF } from 'jspdf'
    export default {
        components: {
        },
        props: {
            link: {
                type: String,
                default: undefined
            }
        },
        data() {
            return {
                base64Code: undefined
            }
        },
        mounted() {
            this.base64Code = qrcode(this.$props.link)
        },
        methods: {
            downloadPDF() {
                const doc = new jsPDF()
                doc.addImage(this.base64Code, 'PNG', 0, 0, 100, 100)
                doc.save(`${Math.random()}.pdf`)
            }
        }
    }
</script>

<style scoped>
</style>